<?php
/**
 * User: 五哥派
 * Date: 2024/6/21 0014
 * Tel(同WX): 17335592719
 */

// 应用公共文件

/**
 * 通用API数据格式输出
 * @param int $count 数量
 * @param array $data 数据
 * @param int $code 状态码
 * @param string $msg 信息
 * @return \think\response\Json 返回输出格式JSON
 */
function showLayui($count = 0, $data=[], $code = 0, $msg='OK'){
    $result = [
        'code' => $code,
        'msg' => $msg,
        'count' => $count,
        'data' => $data,
    ];
    return json($result);
}


/**
 * @param array $data
 * @param string $message
 * @return \think\response\Json
 */
function success($message = "OK", $data = []){
    $result = [
        "code" => 1,
        "msg" => $message,
        "data" => $data
    ];
    return json($result);
}

/**
 * @param string $message
 * @param int $status
 * @param array $data
 * @return \think\response\Json
 */
function error($message = "error", $data = []) {
    $result = [
        "code" => 0,
        "msg" => $message,
        "data" => $data
    ];

    return json($result);
}